home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / misc / TCS.lha / TCS / demos / cod / RmpILBM.s < prev    next >
Encoding:
Text File  |  2000-09-26  |  3.8 KB  |  128 lines

  1. *******************************************************************************
  2. * ILBM loading and remapping example
  3. *******************************************************************************
  4. * INFO    loads a 320x256x8 ILBM with a non-RGBx palette and remaps it
  5. *    to a FullRes screen
  6. * NOTE    - optionally you can pass as CLI argument the name of another
  7. *      320x256x8 ILBM to load (yours must have the same size and
  8. *      must respect all the restrictions of TCS_LdILBM(), otherwise
  9. *      the program won't execute or the graphics will look bad -
  10. *      not dangerous, anyway!)
  11. *    - LMB to quit
  12. *******************************************************************************
  13.  
  14.     machine    68020
  15.  
  16.     include    INCLUDES:libraries/tcs.i
  17.     include    INCLUDES:libraries/tcs_lib.i
  18.     include    /inc/macros.i
  19.  
  20.  
  21.  
  22. *******************************************************************************
  23. * definitions
  24. *******************************************************************************
  25.  
  26. DSPLWD    =    320    ;our TCS display width and
  27. DSPLHT    =    256    ;height (LORES pixels)
  28. SCRWD    =    320    ;TCS screen width and
  29. SCRHT    =    256    ;height (FullRes pixels)
  30. DSPLX0    =    $81*4    ;display start
  31. DSPLY0    =    $2c    ;position (SHRES pixels)
  32. DSPLX1    =    DSPLX0+DSPLWD*4    ;display end
  33. DSPLY1    =    DSPLY0+DSPLHT    ;position (SHRES pixels)
  34. DSPLBRTNS    =    256    ;min brightness
  35. GFXCTXT    =    0    ;graphic context
  36. CWBTM    =    0    ;clipping
  37. CWTOP    =    0    ;window
  38. CWRT    =    0    ;borders
  39. CWLF    =    0    ;coordinates
  40. VDOMODE    =    TCS_VMf_FullRes    ;display video mode
  41.  
  42. ARGSNO    =    2    ;command line arguments No.
  43.  
  44.  
  45.  
  46. *******************************************************************************
  47. * code start
  48. *******************************************************************************
  49.  
  50.     include    /inc/shl_strtup.i
  51.  
  52.  
  53.  
  54. *******************************************************************************
  55. * init
  56. *******************************************************************************
  57.  
  58. _PrgInit    movea.l    CmdLnArgs,a0    ;picture filename address
  59.     tst.l    a0
  60.     bne.s    .ld    ;if filename specified...
  61.     lea.l    PicFlNm,a0    ;default picture
  62. .ld    movea.l    ([DIAdr.l],TCS_DI_CSAdr.w),a1 ;directly to
  63.     move.l    #SCRWD*SCRHT,d0    ;screen buffer
  64.     CALLTCS    LdILBM    ;load it
  65.     cmpi.l    #TCS_PE_OK,d0    ;success?
  66.     blo.s    .fail    ;if not...
  67.     move.l    d0,PicIIAdr    ;else store its ILBMInfo structure address
  68.     rts        ;& clr ccr.Z to signal success
  69. .fail    move.w    #4,ccr    ;signal error
  70.     rts
  71.  
  72.  
  73.  
  74. *******************************************************************************
  75. * main
  76. *******************************************************************************
  77.  
  78. _PrgMain    movea.l    DIAdr,a0
  79.     movea.l    PicIIAdr,a3    ;picture ILBMInfo structure address
  80.  
  81.     movea.l    CmdLnArgs+4,a1
  82.     tst.l    a1
  83.     beq.s    .SuggRGBxMode    ;if user didn't specify a mode...
  84.     move.l    (a1),d3    ;RGBx mode wanted by user
  85.     bra.s    .SetRGBxMode
  86. .SuggRGBxMode    move.b    (TCS_II_RGBxMode,a3),d3    ;RGBx mode suggested for the picture
  87.  
  88. .SetRGBxMode    move.b    d3,d0    ;RGBx mode
  89.     move.w    #256,d1
  90.     CALLTCS    SetRGBxMode    ;set mode for display
  91.  
  92.     movea.l    (TCS_II_GfxAdr,a3),a1    ;address of picture graphics
  93.     movea.l    (TCS_II_PalAdr,a3),a2    ;address of picture palette (CLUT)
  94.     move.b    d3,d0    ;RGBx mode
  95.     move.w    #SCRWD,d1
  96.     move.w    #SCRHT,d2
  97.     movea.l    a1,a0    ;source & destination are the same!
  98.     CALLTCS    CLUTPicToRGBx    ;convert to RGBx
  99.  
  100.     movea.l    DIAdr,a0    ;render FullRes screen
  101.     CALLTCS    CPUFRPass0    ;to make pixels visible
  102.  
  103.     WTLMB
  104.     rts
  105.  
  106.  
  107.  
  108. *******************************************************************************
  109. * cleanup
  110. *******************************************************************************
  111.  
  112. _PrgClnUp    movea.l    PicIIAdr,a0    ;free all the memory
  113.     CALLTCS    UnLdILBM    ;allocated for the picture
  114.     rts
  115.  
  116.  
  117.  
  118. *******************************************************************************
  119. * data
  120. *******************************************************************************
  121.  
  122.     include    /inc/dat.i
  123.  
  124.     cnop    0,4
  125. PicIIAdr    dc.l    0    ;picture ILBMInfo structure address
  126. tmplt    dc.b    "PICTURE=P,RGBxMODE=R/N",0 ;template for ReadArgs()
  127. PicFlNm    dc.b    "/pix/TigerMask.iff",0    ;default picture
  128.